import os
from datetime import date


class DriverConfig:
    driver_env = "chrome"

    driver_path = os.path.join(os.path.join(os.path.join(os.getcwd(), "../chromedriver"),
                                            "chromedriver-win64"),
                               "chromedriver.exe")


class GpApiConfig:
    """
    处理规则
    1、获取30天内数据
        1、近5日为上升趋势
        2、近5日资金净流入为正数
        3、进30日涨停次数大于1次
        4、近3日为调整趋势
    """
    gp_data = 30
    is_up = True
    is_today_down = True
    is_zj_ok = True
    is_month_ok = True


class GpConfig:
    """
    self.day_xpath = '//*[@id="table_ls"]/table/tbody/tr[{}]/td/text()'
        self.zj_xpath = '//*[@id="table_ls"]/table/tbody/tr[{}]/td/span/text()'
    """
    gp_home_xpath = {
        "gp": {
            "url": "https://quote.eastmoney.com/{}.html",
            "main_xpath": {
                "date": '//*[@class="__popfloatwin "]/h4/span/text()',
                "title": '//*[@class="__popfloatwin "]/div/label/text()',
                "result": '//*[@class="__popfloatwin "]/div/span/text()',
                "bks": '//*[@class="xgbk"]/table/tbody/tr/td[1]/a/@href'
            }
        },
        "bk": {
            "url": "https://quote.eastmoney.com/bk/90.{}.html",
            "main_xpath": {
                "date": '//*[@class="__popfloatwin "]/h4/span/text()',
                "title": '//*[@class="__popfloatwin "]/div/label/text()',
                "result": '//*[@class="__popfloatwin "]/div/span/text()',
            }
        }

    }
    gp_zj_xpath = {
        "gp": {
            "url": "https://data.eastmoney.com/zjlx/{}.html",
            "xpath": {
                "date": '//*[@id="table_ls"]/table/tbody/tr[{}]/td/text()',
                "spj": '//*[@id="table_ls"]/table/tbody/tr[{}]/td[2]/span/text()',
                "zdf": '//*[@id="table_ls"]/table/tbody/tr[{}]/td[3]/span/text()',
                "zj": '//*[@id="table_ls"]/table/tbody/tr[{}]/td[4]/span/text()'
            }
        },
        "bk": {
            "url": "https://data.eastmoney.com/bkzj/{}.html",
            "xpath": {
                "date": '//*[@id="table_ls"]/table/tbody/tr[{}]/td/text()',
                "zj": '//*[@id="table_ls"]/table/tbody/tr[{}]/td[2]/span/text()'
            }
        }
    }

    gp_zt_xpath = {
        "gp": {
            "url": "https://quote.eastmoney.com/ztb/detail#type=ztgc",
            "xpath": {
                # 点击加载更多
                "more": "//tfoot",
                # 代码列表
                "dm": '//*[@id="zrzttable"]/tbody/tr/@data-stockcode'
            }
        }
    }


class PathConfig:
    today = date.today()
    # today1 = datetime.today()
    # 股票源地址
    base_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "data")
    # 所有股票池文件地址
    gp_path_chi = os.path.join(base_path, "gp_c.json")
    # 所有板块
    bk_path = os.path.join(base_path, "bk_c.json")

    # 写入地址
    write_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "report")
    # 股票目录
    gp_file_path = os.path.join(write_path, "{}".format(today))

    # 筛选三个条件后的备选池
    gp_path_bx_chi = os.path.join(gp_file_path, "gp_bx_{}.json".format(today))
    # 筛选股票是否最近一个月涨停
    gp_path_bx_zt_chi = os.path.join(gp_file_path, "gp_bx_zt_{}.json".format(today))
    # 筛选板块后的备选池
    gp_path_bk_chi = os.path.join(gp_file_path, "gp_bk_{}.json".format(today))
    # 筛选板块是否涨停的备选池
    gp_path_bk_zt_chi = os.path.join(gp_file_path, "gp_bk_zt_{}.json".format(today))
    # 最后确认的代码
    gp_path_end_chi = os.path.join(gp_file_path, "gp_end_{}.json".format(today))

    # 符合条件的板块
    bk_ok_path = os.path.join(gp_file_path, "bk_ok_{}.json".format(today))

    # 策略配置路径
    celve_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "dev.ini")

class LogPath:
    today = date.today()
    # today1 = datetime.today()
    # 写入地址
    write_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "report")
    # 日志目录
    logs_file_path = os.path.join(write_path, "{}".format(today))
    logs_path = os.path.join(logs_file_path, "gp_{}.log".format(today))


class EamilConfig:
    # 发件人
    msg_from="13386578071@163.com"
    password='****'
    # 收件人
    msg_to=['13386578071@163.com', '1342742938@qq.com']
    # 主题
    subject="推荐股票代码"
    # 发件人
    form_man='量化交易'


if __name__ == '__main__':
    print(PathConfig.celve_path)
